package com.siao.example.socket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.siao.net.socket.Connection;
import com.siao.net.socket.IConnectionHandler;
import com.siao.net.socket.IDataPack;

public class ServerHandler implements IConnectionHandler {

	private static final Logger logger = LoggerFactory.getLogger(ServerHandler.class);

	@Override
	public void onConnected(Connection connection) {
		logger.debug(connection + "onConnected.");
	}

	@Override
	public void onConnectFailed(Connection connection) {
		logger.debug(connection + "onConnectFailed.");
	}

	@Override
	public void onSend(Connection connection, IDataPack data) {
		logger.debug(connection + "onSend.");
	}

	@Override
	public void onReceive(Connection connection, Object data) {
		logger.debug(connection + "onReceive.");

		DataPack pack = (DataPack) data;
		logger.debug("type:" + pack.getType() + ",body:" + new String(pack.getBody()));
	}

	@Override
	public void onClose(Connection connection) {
		logger.debug(connection + "onClose.");
	}

	@Override
	public void onDisconnect(Connection connection) {
		logger.debug(connection + "onDisconnect.");
	}

}
